/*
 * StockTableView.h
 *
 *  Created on: 10.04.2009
 *      Author: Konan Andrej
 */

#ifndef STOCKTABLEVIEW_H_
#define STOCKTABLEVIEW_H_

#include <QMouseEvent>
#include <QSizePolicy>
#include <QTableView>

#include "StockModel.h"
#include "Debug.h"

const int ColumnSize[4] = { 70, 187, 60, 50 };

class StockTableView : public QTableView
{
	Q_OBJECT
private:
	StockModel * stockModel;
	DataBase * DB;

	int SelectedRow;

	void mousePressEvent( QMouseEvent * event );
        void mouseDoubleClickEvent ( QMouseEvent * event );

public slots:
        void RowRemoved();
        void RowInserted();

        void FindItem( const QString& str );
        void GetSelectedItem();

signals:
        void ItemFound();
        void ItemNotFound();
        void NoItemIsSelected();
        void Item( const ItemType& item );

public:
	StockTableView( DataBase * aDB, QWidget * parent = 0 );
        ~StockTableView();

        void SetDatabase( DataBase *db );

        int GetSelectedItem( ItemType& item );
        int getItem( int index, ItemType& item );
        void setFirstColumnSorting( bool flag ) { stockModel->setSortingFlag( flag ); };

        void VarifyColumnWidth();

	int RemoveRow( int row );
	int InsertRow( int row );
};

#endif /* STOCKTABLEVIEW_H_ */
